package com.study.common

import android.os.Handler
import android.os.Looper
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import java.util.concurrent.LinkedBlockingDeque
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit

/**
 * @author thor
 * @description:
 * @date 2024/10/14 19:19
 */
object AppExecutor{
    private const val TAG = "AppExecutor"

    private val fileIO = ThreadPoolExecutor(3, 6, 10, TimeUnit.SECONDS, LinkedBlockingDeque())
    private val netIO = ThreadPoolExecutor(3, 6, 60, TimeUnit.SECONDS, LinkedBlockingDeque())
    private val scheduleIO: ScheduledExecutorService = Executors.newScheduledThreadPool(10)
    private val handler = Handler(Looper.getMainLooper())

    fun fileIO(): ThreadPoolExecutor {
        return fileIO
    }

    fun netIO(): ThreadPoolExecutor {
        return netIO
    }

    fun scheduleIO(): Executor {
        return scheduleIO
    }

    fun mainHandler(): Handler {
        return handler
    }
}
